home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1811 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: rap.SanDiegoCA.ATTGIS.COM!es013!jbc
  2. From: jbc@ElSegundoCA.ATTGIS.COM (Jim Chapman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: deque container - how to implement?
  5. Date: 13 Jan 1996 01:26:42 GMT
  6. Organization: AT&T Global Information Solutions
  7. Distribution: world
  8. Message-ID: <4d71oi$gig@rap.SanDiegoCA.ATTGIS.COM>
  9. References: <4d4c73$qmr@news.xmission.com>
  10. Reply-To: jbc@ElSegundoCA.ATTGIS.COM
  11. NNTP-Posting-Host: es013.elsegundoca.attgis.com
  12.  
  13. In article qmr@news.xmission.com, tknarr@xmission.com  ( Todd Knarr ) writes:
  14. > In <4d1of1$kj7@rap.SanDiegoCA.ATTGIS.COM>, jbc@ElSegundoCA.ATTGIS.COM (Jim Chapman) writes:
  15. > >In STL, deque<T> is supposed to support random access in constant time, so
  16. > >a linked list implemention wouldn't do.  The first poster was closer to
  17. > >the mark. 
  18. > If you want constant-time access, an array is the only way to implement
  19. > it. Unfortunately then your insert time can skyrocket unexpectedly when
  20. > you have to copy the entire pointer array to a bigger array. It can also
  21. > fail completely if you can't allocate the bigger array ( the non-intrusive
  22. > linked-list form can also fail like that, it's just less likely because of
  23. > the smaller blocks of memory involved ). It's a trade-off between the
  24. > operations needed, memory space used, access time and insert time.
  25. The implementation of a deque uses arrays to provide constant-time
  26. access, but adds one level of indirection to gain the storage flexibility
  27. that allows inserts at either end (but not in the middle) to execute
  28. in constant time.
  29.  
  30.  ---
  31.  ====  AT&T        | Jim Chapman             |
  32. =--=== Global      | Multimedia Projects     | jbc@ElSegundoCA.ATTGIS.COM
  33. =--=== Information | 100 N. Sepulveda Blvd.  |   Voice: (310) 524-6747          
  34.  ====  Solutions   | El Segundo, CA 90245    |   FAX:   (310) 524-5515
  35.  
  36.